home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (C) 2002 Tom Parker (tom@carrott.org),
- Matthias Münch (matthias@amigaworld.de)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- In addition, as a special exception, Tom Parker and Matthias Münch give
- permission to link the code of this program with a TCP stack of your
- choice, any official MUI libraries or classes and any custom MUI classes
- that should be necessary for the operation of this program. This
- exception also gives you permission to distribute linked combinations
- including this software with any of the before-mentioned libraries and
- classes. You must obey the GNU General Public License in all respects for
- all of the code used other than that provided by the before-mentioned
- libraries and classes. As part of this exception you are obliged to
- follow the license terms of the before-mentioned libraries, this license
- does not compel you to follow those terms, but if you do not then you may
- not link with those libraries. If you modify this file, you may extend
- this exception to your version of the file, but you are not obligated to
- do so. If you do not wish to do so, delete this exception statement from
- your version.
- */
- /*
- ** xml form class
- */
-
- #include "common.h"
-
- #include <MUI/NListview_mcc.h>
- #include <MUI/NFloattext_mcc.h>
-
- struct xitem
- {
- listitem node;
- char *tag;
- Object *box;
- };
-
- static ULONG xmlform_new(struct IClass *cl, Object *obj, struct opSet *msg);
-
-
- MUI_DISPATCH(xmlform_dispatch)
- {
- switch(msg->MethodID)
- {
- case OM_NEW:
- return xmlform_new(cl, obj, (APTR)msg);
-
- case XMLFORM_PRINT:
- {
- struct xmlformdata *data = INST_DATA(cl,obj);
- struct xitem *xi;
- iks *x, *y;
-
- x = iks_make_iq(IKS_TYPE_SET, NULL);
- iks_insert_attrib(x, "to", iks_id_print(data->pak->from));
- y = iks_find(x, "query");
- xi = list_first(&data->items);
- while(xi)
- {
- iks_insert_cdata(iks_insert(y, xi->tag), convert_utf8(mui_sget(xi->box)), -1);
- xi = list_next(xi);
- }
- if(data->key) iks_insert_cdata(iks_insert(y, "key"), data->key, -1);
-
- return (ULONG)x;
- }
-
- }
- return DoSuperMethodA(cl, obj, msg);
- }
-
-
- static ULONG xmlform_new(struct IClass *cl, Object *obj, struct opSet *msg)
- {
- struct xmlformdata *data;
- ikspak *pak;
- iks *x;
- int regflag = 0;
- Object *inst, *items;
-
- pak = (ikspak *)GetTagData(XMLFORM_PACKET, NULL, msg->ops_AttrList);
- if(!pak) return(NULL);
- x = iks_find(pak->x, "query");
-
- obj = (Object *)DoSuperNew(cl,obj,
- Child, VGroup,
- Child, NListviewObject,
- MUIA_FixHeightTxt, "\n\n\n",
- MUIA_NListview_NList, (ULONG) inst = NFloattextObject,
- ReadListFrame,
- End,
- End,
- Child, (ULONG) items = ColGroup(2), End,
- End,
- TAG_MORE, msg->ops_AttrList);
-
- if(!obj) return(0);
-
- data = INST_DATA(cl,obj);
- data->pak = pak;
-
- x = iks_child(x);
- while(x)
- {
- if(iks_type(x) == IKS_TAG)
- {
- char *tmp = iks_name(x);
- if(strcmp(tmp, "instructions") == 0)
- set(inst, MUIA_NFloattext_Text, (ULONG) iks_cdata(iks_child(x)));
- else if(strcmp(tmp, "registered") == 0)
- regflag = 1;
- else if(strcmp(tmp, "key") == 0)
- data->key = iks_cdata(iks_child(x));
- else
- {
- Object *o, *o2;
- struct xitem *xi;
- xi = malloc(sizeof(struct xitem));
- xi->tag = tmp;
- o = (Object *) Label2(tmp);
- o2 = (Object *) StringObject,
- StringFrame,
- MUIA_String_Contents, convert_locale(iks_cdata(iks_child(x))),
- MUIA_String_AdvanceOnCR, TRUE,
- MUIA_CycleChain, 1,
- End;
- DoMethod(items, OM_ADDMEMBER, o);
- DoMethod(items, OM_ADDMEMBER, o2);
- xi->box = o2;
- list_append(&data->items, xi);
- }
- }
- x = iks_next(x);
- }
-
- return((ULONG)obj);
- }
-
-
- Object *xmlform_create(ikspak *pak)
- {
- return NewObject(gui.xmlform_mcc->mcc_Class, NULL, XMLFORM_PACKET, (ULONG) pak, TAG_DONE);
- }
-
-
- iks *xmlform_print(Object *obj)
- {
- return (iks *)DoMethod(obj, XMLFORM_PRINT);
- }
-